package com.example.hello.mapper;

import com.example.hello.pojo.CreditLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import java.util.List;

@Mapper
public interface CreditLogMapper {
    @Insert("INSERT INTO user_credit_log(" +
            " user_id, `change`, reason, related_id, credit_before, credit_after" +
            ") VALUES(" +
            " #{userId}, #{change}, #{reason}, #{relatedId}, #{creditBefore}, #{creditAfter}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(CreditLog log);

    List<CreditLog> selectByUserId(Long userId);
}